package com.sfx.concurrent.demo.concurrent.ExcutorService;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.SynchronousQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-01-28
 * Time: 18:03
 */

@Slf4j(topic = "c.TestSynchronousQueue")
public class TestSynchronousQueue {
    public static void main(String[] args) throws InterruptedException {
        SynchronousQueue<Integer> queue = new SynchronousQueue<>();
        new Thread(() -> {
            try {
                log.debug("putting{}", 1);
                queue.put(1);
                log.debug("putted{}", 1);

                log.debug("putting{}", 2);
                queue.put(2);
                log.debug("putted{}", 2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "t1").start();
    }
}
